{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->
                <div class="col-sm-12">
                    <div class="layui-form layui-form-item" id="fordaochu">

                        <div class="layui-col-md6 layui-input-inline" style="width:350px;">
                            <input type="text" id="school" class="layui-input search" name="school" value="" placeholder="学校名字/订单号/学生姓名/支付流水号/注册手机"/>
                        </div>
                        <div class="layui-input-inline layui-form">
                            <select name="type" lay-search="" class="layui-input">
                                <option value="">所有类型</option>
                                <option value="1">仅收集</option>
                                <option value="2">仅支付</option>
                                <option value="3">支付和收集</option>
                            </select>
                        </div>
                        <div class="layui-input-inline layui-form">
                            <select name="o_status" id="o_status" lay-search="" class="layui-input">
                                <option  value="">全部订单</option>
                                <option  value="1">待支付</option>
                                <option  value="2">已支付</option>
                            </select>
                        </div>
                        <div class="layui-input-inline layui-form">
                            <input type="text"  name="start" onfocus="wk.lay_date(this);"  class="layui-input layer-date search" placeholder="付款时间-起" />
                        </div>
                        <div class="layui-input-inline layui-form">
                            <input type="text"  name="end" onfocus="wk.lay_date(this);"  class="layui-input layer-date search" placeholder="付款时间-止" />
                        </div>
                        <div class="layui-input-inline" style="width: 300px;">
                            <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                            <button  class="layui-btn layui-btn-normal" id="empty"  lay-submit="" lay-filter="LAY-search">重置</button>
                            <button type="button" onclick="daochu();" class="layui-btn"><i class="layui-icon layui-icon-export"></i>导出</button>
                        </div>
                    </div>
                </div>
                <!--搜索框结束-->
                <!--操作框开始-->

                <!--操作框结束-->
            </div>
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="demo"></table>
                    <script type="text/html" id="status">
                        {{# if(d.status == 1){ }}
                        <span style="color: red;font-weight: bold;">未支付</span>
                        {{# } }}
                        {{# if(d.status == 2){ }}
                        <span style="color: mediumseagreen;font-weight: bold;">已支付</span>
                        {{# } }}
                    </script>
                    <script type="text/html" id="status1">
                        {{d.height}} | {{d.weight}} | {{d.size}}
                    </script>
                    <script type="text/html" id="status2">
                        肩宽：{{d.sw_j}} | 胸围：{{d.sw_x}} | 腰围：{{d.sw_y}} | 臀围：{{d.sw_t}} | 臂长：{{d.sw_b}} | 裤长：{{d.sw_k}}
                    </script>
                    <script type="text/html" id="type">
                        {{# if(d.type == 1){ }}
                        微信
                        {{# } }}
                        {{# if(d.type == 2){ }}
                        支付宝
                        {{# } }}
                    </script>
                    <!--图片模板-->
                    <script type="text/html" id="imgTpl">
                        <img src="{{d.ercode}}" class="img-circle table-img" onerror="this.src='/static/admin/images/head_default.gif'"/>
                    </script>

                    <!--操作模板-->
                    <script type="text/html" id="opeBar">
                        <a href="javascript:;" onclick="wk.confirm('{{d.id}}','{:url('orderdel')}')" class="btn btn-danger btn-xs m-r-xs" title="删除"><i class="fa fa-trash-o">删除</i></a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Offline/order")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 30]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
//                {type: 'checkbox', fixed: 'left',}
                  {type:'numbers', width: 70, title: '序号'}
//                , {field: 'active_id', width: 80, title: 'ID', align: 'center'}
                , {field: 'orderno', width: '', title: '订单号', align: 'center'}
                , {field: 'backno', width: '', title: '支付流水号', align: 'center'}
                , {field: 'school', width: '', title: '学校名称', align: 'center'}
                , {field: 'grade', width: '', title: '年级', align: 'center'}
                , {field: 'class', width: '', title: '班级', align: 'center'}
                , {field: 'name', width: '', title: '学生姓名', align: 'center'}
                , {field: 'sex', width: '', title: '学生性别', align: 'center'}
                , {field: 'idcard', width: '', title: '年份', align: 'center'}
                , {field: 'type', width: '', title: '支付类型', align: 'center', templet: '#type'}
                , {field: 'status', width: '', title: '支付状态', align: 'center', templet: '#status'}
                , {field: 'money', width: '', title: '支付金额', align: 'center'}
                , {field: 'time', width: '', title: '支付时间', align: 'center'}
                , {field: 'height', width: '', title: '身高|体重|尺码', align: 'center', templet: '#status1'}
                , {field: 'sw_j', width: '', title: '三围', align: 'center', templet: '#status2'}
                , {field: 'xiguan', width: '', title: '穿衣习惯', align: 'center'}
                , {field: 'phone', width: '', title: '注册手机', align: 'center'}
                , {field: 'send_name', width: '', title: '收件人', align: 'center'}
                , {field: 'send_address', width: '', title: '收件地址', align: 'center'}
                , {fixed: 'right', width: 100, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $('.img-circle').viewer({
                    url: 'data-original',
                });
            }
        });
    });
    function daochu() {
        var str = '';
        $('#fordaochu .layui-input').each(function (i,d) {
            var name = $(d).attr('name');
            var value = $(d).val();
            if(name && value){
                str += name + '=' + value + '&';
            }
        });
        str = str.slice(0, -1);
        $.ajax({
            url: '/admin/Offline/excelwater',
            data: str,
            type: 'POST',
            dataType: 'JSON',
            success: function (returnData) {
                if(returnData.code == 200){
                    location.href = (returnData.msg);
                }
            },
            error: function () {
                alert('数据出错，请刷新重试');
            }
        })
    }
</script>
</body>
</html>